package IO;

import javafx.print.Printer;

import java.io.*;
import java.util.Scanner;

public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos = new FileOutputStream("pw.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw,true);

        Scanner sc = new Scanner(System.in);
        System.out.println("请开始输入内容");
         while(true) {
             String line = sc.nextLine();
             if ("exit".equals(line)){
                 break;
                 //                 pw.flush();
             }
             pw.println(line);
             System.out.println("请继续输入内容");
             pw.close();
         }

    }

}
